//封装get请求
import store from '../vuex/store'
export function get(url,data=null) {
return	new Promise((resolve,reject)=>{
		uni.request({
			url:url,
			method:"GET",
			data:data,
			success(res) {
				resolve(res)
			},
			fail(res) {
				reject(res)
			}
		})
	})
}
//封装post请求
export function post(url,data=null) {
return	new Promise((resolve,reject)=>{
				// console.log(data)
		uni.request({
			url:url,
			method:"POST",
			data:data,
			success(res) {
				resolve(res)
			},
			fail(res) {
				reject(res)
			}
		})
	})
}
uni.addInterceptor('request',{
				invoke(args) {
				if(args.url.split('wx/')[1]=='home/index'||args.url.split('wx/')[1]=='auth/login'){
					// args.header={};
					// console.log('没有token')
				}else{
					args.header={
						'X-Litemall-Token':store.state.Key
					};
						// console.log('有token')
					
				}
			}
			})

